/*
 * Copyright (c)  2017
 * All rights reserved.
 * ProductInfo.java 2017-09-13 下午7:47
 */

package com.ueboot.weishop.entity.goods;

import com.ueboot.weishop.entity.IDEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;


/**
 * 描述：某个商品的具体规格的值，添加商品时需要对这个商品的规格填写值
 * 示例：
 * 机油商品对应的
 * 一、粘度规格的值：
 * 1.全合成0W-40 SN级
 * 2.全合成5W-40 SN级
 * 二、容量的值：
 * 1. 1L
 * 2. 4L
 *
 * @author yangkui create on 2017-09-13 下午7:47.
 * @since 1.0
 */
@Data
@NoArgsConstructor
@Entity(name = "WS_GOODS_SPEC_VALUE")
public class GoodsSpecValueEntity extends IDEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "WS_GOODS_SPEC_VALUE")
    @GenericGenerator(name = "WS_GOODS_SPEC_VALUE", strategy = "enhanced-table", parameters = {
            @org.hibernate.annotations.Parameter(name = "table_name", value = "WS_TABLE_SEQUENCE"),
            @org.hibernate.annotations.Parameter(name = "segment_value", value = "WS_GOODS_SPEC_VALUE"),
            @org.hibernate.annotations.Parameter(name = "optimizer", value = "pooled") })
    @Column(name = "ID",columnDefinition = "INT(20) COMMENT 'id主键'",length = 20)
    private Long id;

    /**
     * 具体的规格名称
     */
    @Column(name = "NAME",columnDefinition = "VARCHAR(200) COMMENT '具体的规格名称'",length = 200)
    private String name;

    /**
     * 具体的规格值
     */
    @Column(name = "VALUE",columnDefinition = "VARCHAR(200) COMMENT '具体的规格值'",length = 200)
    private String value;

    /**
     * 规格值排序，用于页面显示使用。值越大越靠前
     */
    @Column(name = "RANK",columnDefinition = "INT(11) COMMENT '规格排序，用于页面显示使用。值越大越靠前'",length = 11)
    private int rank;


    /**
     * 所属商品的规格
     */
    @ManyToOne
    @JoinColumn(name="GOODS_SPEC_ID",columnDefinition = "INT(20) COMMENT '所属商品的规格'")
    private GoodsSpecEntity goodsSpec;

    /**
     * 所属的商品(冗余字段)
     */
    @ManyToOne
    @JoinColumn(name="GOODS_INFO_ID",columnDefinition = "INT(20) COMMENT '所属商品'")
    private GoodsInfoEntity goodsInfo;

}